import {request} from '../../request/request'
Page({
    data: {
        commodity:[]
    },
    commodity_url:'',
    onLoad: function (options) {
        var tit;
        this.commodity_url = options.url;
        switch(options.url){
            case "/get-vegetable":
              tit = "蔬菜类";
            break;
            case "/get-fruits":
              tit = "水果类";
            break;
            case "/get-food":
              tit = "食品类";
            break;
            case "/get-OTCDrugs":
              tit = "OTC药品类";
            break;
            case "/get-otherGoods":
              tit = "其他商品类";
            break;
        }
        wx.setNavigationBarTitle({
          title: tit
        })
        this.getCommodity();
    },
    getCommodity(){
        request({
          url: this.commodity_url
        }).then((result)=>{
          console.log(result);
          this.setData({
            commodity:result.data
          })
          wx.stopPullDownRefresh();  
        })
    },
    onPullDownRefresh:function(){
      this.setData({
        commodity:[]
      })
      this.getCommodity();
  }
})